package com.watson.grpc;

import com.watson.grpc.anno.GrpcService;
import com.watson.grpc.config.GrpcLauncher;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Map;

/**
 * @Author watson
 * @Date 2022/7/4 15:11
 * @Description: http://www.demodashi.com/demo/14110.html
 * @Version 1.0
 */
@SpringBootApplication
public class GrpcApplication {
    public static void main(String[] args) {
        // 启动SpringBoot web
        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(GrpcApplication.class, args);
        Map<String, Object> grpcServiceBeanMap =  configurableApplicationContext.getBeansWithAnnotation(GrpcService.class);
        GrpcLauncher grpcLauncher = configurableApplicationContext.getBean("grpcLauncher", GrpcLauncher.class);
        grpcLauncher.grpcStart(grpcServiceBeanMap);
    }
}
